package com.sanhe.roller.activity;

import static com.menu.app.util.FunctionCode.START1;
import static com.menu.app.util.FunctionCode.START2;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.MenuProvider;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;

import com.menu.app.activity.BaseBoardActivity;
import com.menu.app.bean.Command;
import com.menu.app.util.port.SerialManage;
import com.sanhe.roller.util.Crc16Utils;

public class BoardActivity extends BaseBoardActivity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding.camera.setVisibility(View.INVISIBLE);

    }

    @Override
    protected String getReportUrl() {
        return null;
    }


    @Override
    protected void checkState(boolean jump) {
        if (jump) {
            toWork();
        }
    }

    @Override
    protected boolean checkHandle(Runnable runnable) {
        return true;
    }

    @Override
    protected void doUpdateRent(Command bean, Runnable runnable) {
        super.doUpdateRent(bean, runnable);
//
//        hideLoading();
//        h.post(() -> runnable.run());

//        App.getApp().setIgnore(false);
////        sendTouchEvent((byte) 0, (byte) 3);
//        sendTouchEvent((byte) 0, (byte) 0x92);
    }

    @Override
    protected void sendTouchEvent(byte data_H, byte data_L) {
        byte[] tmp = {(byte) 0x83, (byte) 0x10, 1, 1, data_H, data_L};
        tmp = Crc16Utils.getData(tmp);
        byte[] touch_event = new byte[11];
        touch_event[0] = START1;
        touch_event[1] = START2;
        touch_event[2] = 8;
        System.arraycopy(tmp, 0, touch_event, 3, tmp.length);
        SerialManage.getInstance().send(touch_event);
    }

    @Override
    public void addMenuProvider(@NonNull MenuProvider provider, @NonNull LifecycleOwner owner, @NonNull Lifecycle.State state) {

    }
}

